package com.nanhai.buddhist.college.module.study.dal.mysql.attendancemanagement;

import com.nanhai.buddhist.college.framework.common.pojo.PageResult;
import com.nanhai.buddhist.college.framework.mybatis.core.mapper.BaseMapperX;
import com.nanhai.buddhist.college.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.nanhai.buddhist.college.module.study.controller.admin.attendancemanagement.vo.AttendanceManagementExportReqVO;
import com.nanhai.buddhist.college.module.study.controller.admin.attendancemanagement.vo.AttendanceManagementPageReqVO;
import com.nanhai.buddhist.college.module.study.controller.student.attendance.vo.StudentManagementPageReqVO;
import com.nanhai.buddhist.college.module.study.controller.teacher.vo.ManagementCheckPageReqVO;
import com.nanhai.buddhist.college.module.study.dal.dataobject.attendancemanagement.AttendanceManagementDO;
import com.nanhai.buddhist.college.module.study.dal.dataobject.classclockrecord.ClockRecordDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 考勤管理 Mapper
 *
 * @author HeShuai
 */
@Mapper
public interface AttendanceManagementMapper extends BaseMapperX<AttendanceManagementDO> {

    default PageResult<AttendanceManagementDO> selectPage(AttendanceManagementPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AttendanceManagementDO>()
                .likeIfPresent(AttendanceManagementDO::getUserName,reqVO.getUserName())
                .betweenIfPresent(AttendanceManagementDO::getLeaveStartTime, reqVO.getLeaveStartTime())
                .betweenIfPresent(AttendanceManagementDO::getLeaveEndTime, reqVO.getLeaveEndTime())
                .eqIfPresent(AttendanceManagementDO::getUserType, reqVO.getUserType())
                .eqIfPresent(AttendanceManagementDO::getUserPhone, reqVO.getUserPhone())
                .eqIfPresent(AttendanceManagementDO::getCopySendId, reqVO.getCopySendId())
                .eqIfPresent(AttendanceManagementDO::getApprovalStatus, reqVO.getApprovalStatus())
                .orderByDesc(AttendanceManagementDO::getCreateTime));
    }

    default List<AttendanceManagementDO> selectList(AttendanceManagementExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<AttendanceManagementDO>()
                .betweenIfPresent(AttendanceManagementDO::getLeaveStartTime, reqVO.getLeaveStartTime())
                .betweenIfPresent(AttendanceManagementDO::getLeaveEndTime, reqVO.getLeaveEndTime())
                .eqIfPresent(AttendanceManagementDO::getApprovalStatus, reqVO.getApprovalStatus())
                .orderByDesc(AttendanceManagementDO::getCreateTime));
    }
    default PageResult<AttendanceManagementDO> selectPage1(StudentManagementPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AttendanceManagementDO>()
                .eqIfPresent(AttendanceManagementDO::getApprovalStatus, reqVO.getApprovalStatus())
                .geIfPresent(AttendanceManagementDO::getLeaveStartTime, reqVO.getLeaveStartTimeDate())
                .leIfPresent(AttendanceManagementDO::getLeaveEndTime, reqVO.getLeaveEndTimeDate())
                .eqIfPresent(AttendanceManagementDO::getUserId,reqVO.getUserId())
                .eqIfPresent(AttendanceManagementDO::getUserType,reqVO.getUserType())
                .eqIfPresent(AttendanceManagementDO::getCollegeId,reqVO.getCollegeId())
                .orderByDesc(AttendanceManagementDO::getCreateTime));
    }

    default PageResult<AttendanceManagementDO> selectPage2(ManagementCheckPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AttendanceManagementDO>()
                .betweenIfPresent(AttendanceManagementDO::getLeaveStartTime, reqVO.getLeaveStartTime())
                .betweenIfPresent(AttendanceManagementDO::getLeaveEndTime, reqVO.getLeaveEndTime())
                .eqIfPresent(AttendanceManagementDO::getApprovalStatus, reqVO.getApprovalStatus())
                .eqIfPresent(AttendanceManagementDO::getCopySendId,reqVO.getCopySendId())
                .eqIfPresent(AttendanceManagementDO::getUserType,reqVO.getUserType())
                .eqIfPresent(AttendanceManagementDO::getReasonId,reqVO.getReasonId())
                .eqIfPresent(AttendanceManagementDO::getApprovalStatus,reqVO.getApprovalStatus())
                .orderByDesc(AttendanceManagementDO::getCreateTime));
    }

    default PageResult<AttendanceManagementDO> selectPageApp(ManagementCheckPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AttendanceManagementDO>()
                .betweenIfPresent(AttendanceManagementDO::getLeaveStartTime, reqVO.getLeaveStartTime())
                .betweenIfPresent(AttendanceManagementDO::getLeaveEndTime, reqVO.getLeaveEndTime())
                .inIfPresent(AttendanceManagementDO::getApprovalStatus, reqVO.getApprovalStatuses())
                .eqIfPresent(AttendanceManagementDO::getCopySendId,reqVO.getCopySendId())
                .eqIfPresent(AttendanceManagementDO::getUserType,reqVO.getUserType())
                .eqIfPresent(AttendanceManagementDO::getReasonId,reqVO.getReasonId())
                .eqIfPresent(AttendanceManagementDO::getApprovalStatus,reqVO.getApprovalStatus())
                .orderByDesc(AttendanceManagementDO::getCreateTime));
    }


}
